import java.util.Scanner;

public class PrefixSum {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] arr=new int[n];
        long[] arrs=new long[n+1];
        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
            arrs[i+1]=arrs[i]+arr[i];
        }
        while(m-->0){
            int l=sc.nextInt();
            int r=sc.nextInt();
            System.out.println(arrs[r]-arrs[l-1]);
        }
    }
}
